package pers.litao.bit.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import pers.litao.bit.commons.entities.priduct.UnitEntity;
import pers.litao.bit.commons.utils.R;
import pers.litao.bit.commons.utils.SysUtil;
import pers.litao.bit.product.dao.UnitMapper;
import pers.litao.bit.product.service.UnitService;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 李涛
 * @date 2020-11-26 15:46
 */
@Service
@Slf4j
public class UnitServiceImpl extends ServiceImpl<UnitMapper, UnitEntity> implements UnitService {
    @Override
    public void init() {
        List<UnitEntity> unitEntities = new ArrayList<>();
        unitEntities.add(new UnitEntity(null,"千克","kg",null));
        unitEntities.add(new UnitEntity(null,"克","g",null));
        unitEntities.add(new UnitEntity(null,"吨","t",null));
        unitEntities.add(new UnitEntity(null,"件","",null));
        unitEntities.add(new UnitEntity(null,"双","",null));
        unitEntities.add(new UnitEntity(null,"套","",null));
        unitEntities.add(new UnitEntity(null,"个","",null));
        unitEntities.add(new UnitEntity(null,"张","",null));
        unitEntities.add(new UnitEntity(null,"袋","",null));
        unitEntities.add(new UnitEntity(null,"组","",null));
        unitEntities.add(new UnitEntity(null,"台","",null));
        unitEntities.add(new UnitEntity(null,"箱","",null));
        unitEntities.add(new UnitEntity(null,"桶","",null));
        unitEntities.add(new UnitEntity(null,"包","",null));
        unitEntities.add(new UnitEntity(null,"米","m",null));
        unitEntities.add(new UnitEntity(null,"平方米","m^2",null));
        unitEntities.add(new UnitEntity(null,"升","l",null));
        unitEntities.add(new UnitEntity(null,"毫升","ml",null));
        this.saveBatch(unitEntities);
    }

    /**
     * 获取单位列表
     *
     * @return
     */
    @Override
    public R getUnitList() {
        log.info("用户请求成功" + SysUtil.getClientInfo().buildInfo());
        return R.ok(this.list());
    }
}
